package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbItemMapper;
import com.dongdongshop.seller.pojo.TbItem;
import com.dongdongshop.seller.pojo.TbItemExample;
import com.dongdongshop.seller.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


import java.util.List;

@Component
@Service
public class itemServiceImpl implements ItemService {

    @Autowired
    private TbItemMapper itemMapper;

    @Override
    public List<TbItem> selectbygoodsid(Long goodsId) {
        TbItemExample example = new TbItemExample();
        TbItemExample.Criteria criteria = example.createCriteria();
        criteria.andStatusEqualTo("1");
        criteria.andGoodsIdEqualTo(goodsId);
        example.setOrderByClause("is_default desc");
        List<TbItem> tbItems = itemMapper.selectByExample(example);
        return tbItems;
    }

    @Override
    public TbItem getItemByid(Long itemId) {
        TbItem item = itemMapper.selectByPrimaryKey(itemId);
        return item;
    }
}
